 <%@ page language="java" import="java.util.*" pageEncoding="utf-8" isELIgnored="false"%>

<%@ page import="com.spoto.oa.model.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.spoto.oa.util.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>公告编辑</title>
    
    <link href="style/v1/common/welcome.css" rel="stylesheet" />
    <script type="text/javascript" src="js/lib/jquery-1.4.2.js">
</script>
<script src="js/common/list.js" type="text/javascript">
</script>
<script src="js/common/welcome.js" type="text/javascript">
</script>
<style type="text/css">
.img{background:url(style/v1/images/notice.png) no-repeat; width:24px; height:24px;}

</style>
<link href="style/v1/common/form.css" rel="stylesheet" type="text/css" />
  </head>
  
  <body>
    <div id="welcome">
			<div class="label">
				<div class="img">
				</div>
				<h2>
					公告编辑
				</h2>
			</div>
			
			<div class="ope">
				<form class="form" action="NoticeServlet" method="post">
				<input type="hidden" name="op_type"
						value="search" />
					<input type="hidden" name="searchTypeValue" id="searchTypeValue"
						value="${searchType}" />
					<ul>
						<li>
							公告类型:
							<select name="searchType" id="searchType">

									<%
							List<NoticeType> noticeTypes = (List<NoticeType>) request
									.getAttribute("noticeTypes");
							Iterator<NoticeType> i = noticeTypes.iterator();
							while (i.hasNext()) {
								NoticeType noticeType = i.next();
						%>
						<option name="type">
						<%=noticeType.getName() %>
						</option>
						<%
							}
						%>

							</select>
							公告标题:<input type="text" name="infor" id="" value="${infor}">
					        <input type="submit" value="查询" class="search">
						</li>
					</ul>	
					
				</form>				
			</div>
			<%
				String type=request.getParameter("op_type");
				Object ob = request.getAttribute("notices");
				if (null != ob) {
					PageUtil pc = new PageUtil();
					String searchType = request.getParameter("searchType");
					String info = request.getParameter("infor");
					pc.setCurrentPage(request.getParameter("page"));	//设置当前页面
					pc.setPageCount(2);		//设置每页记录数
					pc.setRecordCount(((List<Notice>) ob).size());	//设置记录条数
					pc.setPageUrl("NoticeServlet?op_type=" + type + "&searchType="
							+ searchType + "&infor=" + info); //设置跳转页面url
					List<Notice> notices = pc.getSubList((List<Notice>) ob); //获取当前页面记录
					if (notices.isEmpty()) {
			%>
				<div id="no-exist">不存在公告</div>
			<%
				} else {
			%>
			     <div id="list">
                <form action="NoticeServlet?op_type=multi_del" method="post">
                    <div id="table-ope-left">
							<input type="hidden" name="op_type" value="multi_del" />
							<button type="button" class="select_btn" name="select_all">
								全选
							</button>
							<button type="button" class="select_btn" name="select_reverse">
								反选
							</button>
							<button type="button" class="select_btn" name="select_cancel">
								取消
							</button>
							<input type="submit" id="mul-del" value="删除选中" />
						</div>
						<div id="table-ope-right">
							<%=pc.getPageJumpLinkHtml()%>
						</div>
						<div id="c"></div>
                    <table class="table">
                        <tr class="firstrow">
                            <td>
                                公告标题
                            </td>
                            <td>
                                公告类型
                            </td>
                            <td>
                                公告发布者
                            </td>
                            <td>
                                公告发布时间
                            </td>
                            <td>
                                操作
                            </td>
                        </tr>
                        <tr>
                        <%
									for (Notice e : notices) {
						%>
                           <td style="text-align:left">
                           	    
								<input type="checkbox" name="del-flag" value="<%=e.getId()%>"/>
								<a href="NoticeServlet?id=<%=e.getId()%>&op_type=to_update" class="update_a"><%
									out.print(e.getTitle());
								%></a>
							</td>
                            <td>
                            <%=e.getType() %>
                           
                            </td>
                            <td>
                             <%=e.getCreator() %>
                            
                            </td>
                            <td>
                            <%=e.getCreate_date() %>
                            </td>
                            <td>
                                <a href="NoticeServlet?id=<%=e.getId()%>&op_type=delete" onclick="return isDelete()">删除</a>
                                <a href="NoticeServlet?id=<%=e.getId()%>&op_type=to_update" class="update_a">修改</a>
                            </td>
                        </tr>
                        <%
                        	}
                         %>
                         </table>
                </form>
                <div class="page-no">
						<ul>
							<%=	pc.getJavaScriptJumpCode() %>
							<li id="statue">
								<%=pc.getPageCountHtml()%>
							</li>
							<li class="jump">
								<%=pc.getPageFormJumpHtml()%>
							</li>
						</ul>

					</div>		
                       <%
                       }
                }
                 %>
                   
               		
            </div>
			


		</div>
  </body>
</html>
